<template>
  <view class="page">
    <view class="records">
      <view class="records-title">数据记录</view>
      <view class="records-flex">
        <view class="records-flex1">
          <view class="text">{{ statistics.week }}</view>
          <view class="text1">本周提现</view>
        </view>
        <view class="records-flex1">
          <view class="text">{{ statistics.month }}</view>
          <view class="text1">本月提现</view>
        </view>
        <view class="records-flex1">
          <view class="text">{{ statistics.total }}</view>
          <view class="text1">累计提现</view>
        </view>
      </view>
    </view>
    <view class="segmented">
      <SegmentedControl
        class="control"
        :current="current"
        :style="{ height: '88rpx' }"
        :values="items"
        :style-type="styleType"
        :active-color="activeColor"
        @clickItem="onClickItem"
      />
    </view>
    <view class="list" v-if="statisticsList.length > 0">
      <view
        class="list-flex"
        v-for="(item, index) in statisticsList"
        :key="index"
      >
        <view>
          <view class="list-title">提现</view>
          <view class="list-time">{{ item.createTime.slice(0, 16) }}</view>
        </view>
        <view>
          <view class="list-pirce">{{ item.topupAmount }}</view>
          <view class="list-type" v-if="item.status == 1">待审核</view>
          <view class="list-type" v-if="item.status == 2">待打款</view>
          <view class="list-type" v-if="item.status == 3">已打款</view>
          <view class="list-type" v-if="item.status == 4">已驳回</view>
          <view class="list-type" v-else></view>
        </view>
      </view>
    </view>
    <Empty v-else />
  </view>
</template>

<script>
import mineApi from "@/api/mine";
import SegmentedControl from "@/components/segmented-control/index.vue";
export default {
  name: "setup",
  components: {
    SegmentedControl,
  },
  data() {
    return {
      items: ["全部", "待审核", "待打款", "已打款", "已驳回"],
      current: 0,
      activeColor: "#000",
      styleType: "text",
      statistics: {},
      statisticsList: [],
    };
  },
  onLoad(options) {
    this.getStatistics();
    this.getStatisticsList();
  },
  onShow() {},
  methods: {
    getStatistics() {
      mineApi.getStatistics().then((res) => {
        this.statistics = res.data;
      });
    },
    getStatisticsList() {
      mineApi.getStatisticsList({ status: this.current }).then((res) => {
        if (res.code == 200) {
          this.statisticsList = res.rows;
        }
      });
    },
    toggle() {
      this.$refs.popup.open();
    },
    withdraw() {
      this.$refs.popup1.open();
    },
    onClickItem(e) {
      this.current = e.currentIndex;
      this.getStatisticsList();
    },
  },
};
</script>

<style lang="scss" scoped>
.page {
  background: #fff;
  width: 100vw;
  height: 100vh;
  padding-top: 20rpx;
  // text-align: center;
}

.segmented {
  width: 100%;
  box-shadow: 0 4rpx 6rpx 0 #00000026;
  margin-top: 20rpx;
}

.segmented > .uni-segmented-control {
  height: 88rpx !important;
}

/* 假设你的组件类名为 .uni-segmented-control */
.segmented .uni-segmented-control .uni-sc-item {
  color: grey !important;
  /* 未激活的颜色 */
}

.list {
  margin-top: 10rpx;
}

.list-flex {
  margin: 30rpx 30rpx 0rpx 30rpx;
  padding-bottom: 30rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #efefef;

  .list-title {
    color: #000000;
    font-family: "PingFang SC";
    font-size: 26rpx;
    font-style: normal;
    font-weight: 500;
    line-height: normal;
    opacity: 0.9;
  }

  .list-time {
    color: #000000;
    font-family: "PingFang SC";
    font-size: 20rpx;
    font-style: normal;
    font-weight: 400;
    line-height: normal;
    opacity: 0.5;
    margin-top: 8rpx;
  }

  .list-pirce {
    color: #000000;
    text-align: right;
    font-family: "PingFang SC";
    font-size: 32rpx;
    font-style: normal;
    font-weight: 500;
    line-height: normal;
    opacity: 0.9;
  }

  .list-type {
    color: #ff4254;
    text-align: right;
    font-family: "PingFang SC";
    font-size: 20rpx;
    font-style: normal;
    font-weight: 400;
    line-height: normal;
  }
}

.card {
  margin: 30rpx 30rpx 0 30rpx;
  width: 690rpx;
  height: 308rpx;
  border-radius: 12rpx;
  background: linear-gradient(298deg, #1e1f26 0%, #1e1f268c 100%);
  padding: 37rpx 0 0 40rpx;

  .card-title {
    color: #ffffff;
    font-family: "PingFang SC";
    font-size: 28rpx;
    font-style: normal;
    font-weight: 600;
    line-height: normal;
  }

  .card-num {
    color: #ffffff;
    font-family: "PingFang SC";
    font-size: 64rpx;
    font-style: normal;
    font-weight: 600;
    line-height: normal;
    margin-top: 10rpx;
  }

  .card-flex {
    display: flex;
    justify-content: space-between;
  }

  .card-text {
    color: #ffffff;
    font-family: "PingFang SC";
    font-size: 28rpx;
    font-style: normal;
    font-weight: 500;
    line-height: 40rpx;
  }

  .mt-8 {
    margin-top: 8rpx;
  }

  .mt-30 {
    margin-top: 30rpx;
  }

  .mr-20 {
    margin-right: 20rpx;
  }

  .btn {
    width: 164rpx;
    height: 80rpx;
    flex-shrink: 0;
    border-radius: 16rpx;
    border: 2rpx solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-family: "PingFang SC";
    font-size: 30rpx;
    font-style: normal;
    font-weight: 400;
    line-height: normal;
    margin-right: 40rpx;
  }

  .btn1 {
    width: 164rpx;
    height: 80rpx;
    flex-shrink: 0;
    border-radius: 16rpx;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000000;
    font-family: "PingFang SC";
    font-size: 30rpx;
    font-style: normal;
    font-weight: 400;
    line-height: normal;
    margin-right: 20rpx;
  }
}

.records {
  width: 690rpx;
  height: 172rpx;
  flex-shrink: 0;
  border-radius: 24rpx;
  background: var(--f-8-f-8-f-8, #f8f8f8);
  padding: 20rpx 24rpx;
  margin: 20rpx 30rpx;

  .records-title {
    color: #000000;
    font-family: "PingFang SC";
    font-size: 28rpx;
    font-style: normal;
    font-weight: 500;
    line-height: 40rpx;
  }

  .records-flex {
    display: flex;
    justify-content: space-around;
    margin-top: 20rpx;
  }

  .records-flex1 {
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
  }

  .text {
    color: #000000;
    text-align: center;
    font-family: "PingFang SC";
    font-size: 32rpx;
    font-style: normal;
    font-weight: 500;
    line-height: 32rpx;
  }

  .text1 {
    color: #000000;
    text-align: center;
    font-family: "PingFang SC";
    font-size: 24rpx;
    font-style: normal;
    font-weight: 400;
    line-height: 24rpx;
    opacity: 0.5;
    margin-top: 14rpx;
  }
}
</style>
